Step3 : Component

  • STEPS

    Step1: create component

    1. extend class

                      
                        class ExpenseEntryItem extends React.Component { 
    
                        }
    
    
                        

    2. create render function

    
                        class ExpenseEntryItem extends React.Component { 
                            render() { 
                                
                            } 
                        }
    
                        

    3. create UI

    
                        class ExpenseEntryItem extends React.Component {
                        render() {
                            return (
                                <div>
                                    <div><b>Item:</b> <em>Mango Juice</em></div>
                                    <div><b>Amount:</b> <em>30.00</em></div>
                                    <div><b>Spend Date:</b> <em>2020-10-10</em></div>
                                    <div><b>Category:</b> <em>Food</em></div>
                                </div>
                            );
                        }
                        }
    
                        
    complete web page
    
    
                        <div id="react-app"></div>
           
                        <script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
                        <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>
                        <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
    
    
                        <script type="text/babel">
                        class ExpenseEntryItem extends React.Component {
                            render() {
                            return (
                                <div>
                                    <div><b>Item:</b> <em>Mango Juice</em></div>
                                    <div><b>Amount:</b> <em>30.00</em></div>
                                    <div><b>Spend Date:</b> <em>2020-10-10</em></div>
                                    <div><b>Category:</b> <em>Food</em></div>
                                </div>
                            );
                            }
                        }
                        ReactDOM.render(
                            <ExpenseEntryItem />,
                            document.getElementById('react-app') );
                            
                    </script>